import hashlib
import os

fl = "XRrecord"


def toHashMd5(file):
    """创建md5哈希值"""
    with open(file, "rb") as f:
        return hashlib.md5(f.read()).hexdigest().upper()


def saveMd5(md5, size):
    """保存md5哈希值"""
    with open(f"{fl}.md", "w") as f:
        f.write(f"{md5} {size}\n")


if __name__ == "__main__":
    print("Hello, World!")
    md5 = toHashMd5(f"{fl}.exe")
    saveMd5(md5, os.path.getsize(f"{fl}.exe"))
